//!
/************************************************************************************************************
 * @file RBTimer_Win32.cpp
 ************************************************************************************************************/

/************************************************************************************************************
 * Precompiled Header
 ************************************************************************************************************/
#include "RBMainPCH.h"

/************************************************************************************************************
 * Includes
 ************************************************************************************************************/

#include <RBMain/RBTimer.h>

#include <RBMain/RBMemoryManagerOff.h>
#include <windows.h>
#include <RBMain/RBMemoryManagerOn.h>

/************************************************************************************************************
 * Defines
 ************************************************************************************************************/

/************************************************************************************************************
 * Implementation
 ************************************************************************************************************/

float32 RBTimer::GetTime() const
{
    static LARGE_INTEGER liFreq;
    static bool first = true;
    static float32 ms_Freq = 0.0f;
    if (first)
    {
        ::QueryPerformanceFrequency(&liFreq);
        ms_Freq = 1.0f / liFreq.QuadPart;
        first = false;
    }
    LARGE_INTEGER liCurrentTick;
    ::QueryPerformanceCounter(&liCurrentTick);
    uint32 uiPrecision = 10000;
    float32 fTime = static_cast<float32>(uiPrecision * liCurrentTick.QuadPart / liFreq.QuadPart) / static_cast<float32>(uiPrecision);
    return fTime - m_fCreationTime;
};

/************************************************************************************************************/
